package com.FrameWork.Common;

import com.SFA.R;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.AdapterView;
import android.widget.ListView;

/**
 * 圆角ListView示例
 * 
 * @Description: 圆角ListView示例
 */
public class myListView extends ListView
{
	public void init()
	{
		this.setVerticalScrollBarEnabled(false);
		this.setFooterDividersEnabled(true);
		//this.setChoiceMode(ListView.CHOICE_MODE_NONE);
	}
	public myListView(Context context)
	{
		super(context);
		init();
	}

	public myListView(Context context, AttributeSet attrs, int defStyle)
	{
		super(context, attrs, defStyle);
		init();
	}

	public myListView(Context context, AttributeSet attrs)
	{
		super(context, attrs);
		init();
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev)
	{
		switch (ev.getAction())
		{
		case MotionEvent.ACTION_DOWN:
			int x = (int) ev.getX();
			int y = (int) ev.getY();
			int itemnum = pointToPosition(x, y);

			if (itemnum == AdapterView.INVALID_POSITION)
				break;
			else
			{
				if (itemnum == 0)
				{
					if (itemnum == (getAdapter().getCount() - 1))
					{
						setSelector(R.drawable.app_list_corner_round);
					}
					else
					{
						setSelector(R.drawable.app_list_corner_round_top);
					}
				}
				else
					if (itemnum == (getAdapter().getCount() - 1))
						setSelector(R.drawable.app_list_corner_round_bottom);
					else
					{
						setSelector(R.drawable.app_list_corner_shape);
					}
			}

			break;
		case MotionEvent.ACTION_UP:
			break;
		}

		return super.onInterceptTouchEvent(ev);
	}
}